package com.x.netty.oio;

import java.io.*;
import java.net.Socket;

/**
 * 时间客户端
 *
 * @author _G5niusX
 * @date 2018/5/16
 */
public class OIOTimeClient {
    public static void main(String[] args) throws IOException {
        try (Socket socket = new Socket("127.0.0.1", OIOTimeServer.PORT);
             InputStream inputStream = socket.getInputStream();
             OutputStream outputStream = socket.getOutputStream();
             BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
             BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
        ) {
            /*由于服务端读取的时候使用了BufferedReader,默认会忽略LF标志,所以手动增加LF标志*/
            bufferedWriter.write("test\r\n");
            bufferedWriter.flush();
            String readLine = bufferedReader.readLine();
            System.out.println("readLine = " + readLine);
        } catch (Exception e) {

        }
    }
}
